﻿Public Class FacturaVentaDAL
    Public Shared Function Create(zFacturaVenta As facturasventa) As facturasventa
        Try
            Using bd As New gas_gasdesuvecinoEntities
                bd.facturasventa.Add(zFacturaVenta)
                bd.SaveChanges()
                Return zFacturaVenta
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

    Public Shared Function Update(zFacturaVenta As facturasventa) As facturasventa
        Try
            Using bd As New gas_gasdesuvecinoEntities
                Dim fact = bd.facturasventa.Find(zFacturaVenta.FACTURAID)
                With fact
                    .DESCRIPCION = zFacturaVenta.DESCRIPCION
                    .FECHAEMISION = zFacturaVenta.FECHAEMISION
                    .IVA = zFacturaVenta.IVA
                    .CLIENTE = zFacturaVenta.CLIENTE
                    .MONTONETO = zFacturaVenta.MONTONETO
                    .NUMEROFACTURA = zFacturaVenta.NUMEROFACTURA
                    .TOTAL = zFacturaVenta.TOTAL
                End With
                bd.SaveChanges()
                Return fact
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
    Public Shared Function SearchById(zId As Long) As facturasventa
        Try
            Using bd As New gas_gasdesuvecinoEntities
                Return bd.facturasventa.Find(zId)
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
    Public Shared Function delete(zfactura As facturasventa) As Boolean
        Try
            Using bd As New gas_gasdesuvecinoEntities
                bd.facturasventa.Remove(zfactura)
                Return True
            End Using
        Catch ex As Exception
            Return False
        End Try
    End Function

End Class
